<include file="public/layout" />

<script src="__ROOT__/public/static/js/layer/laydate/laydate.js"></script>

<body style="background-color: #FFF; overflow: auto;">

<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>

<div id="append_parent"></div>

<div id="ajaxwaitid"></div>

<div class="page">

    <div class="fixed-bar">

        <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>

            <div class="subject">

                <h3>微信消息管理 - 编辑微信消息</h3>

                <h5>网站系统微信消息管理</h5>

            </div>

        </div>

    </div>

    <form class="form-horizontal" id="handleposition" method="post">

        <input type="hidden" name="id" value="{$wxmessage.id}"/>

        <div class="ncap-form-default">
           

            <dl class="row">

                <dt class="tit">

                    <label><em>*</em>微信消息名称</label>

                </dt>

                <dd class="opt">

                    <input type="text" id="name" name="title" value="{$wxmessage.title}" class="input-txt">

                    <p class="notic">请填写微信消息名称</p>

                </dd>

            </dl>

            <dl class="row">

                <dt class="tit">

                    <label><em>*</em>微信消息内容</label>

                </dt>

                <dd class="opt">

                    <textarea name="content" style="width:80%;height: 100px">{$wxmessage.content}</textarea> 

                    <p class="notic">请填写微信消息内容</p>

                </dd>

            </dl>

            <dl class="row">

                <dt class="tit">

                    <label><em>*</em>跳转链接</label>

                </dt>

                <dd class="opt">

                    <input type="text" id="link" name="link" value="{$wxmessage.link}" class="input-txt">

                    <p class="notic">模板消息点击后跳转链接</p>

                </dd>

            </dl>
            <dl class="row">

                <dt class="tit">

                    <label><em>*</em>微信消息模板</label>

                </dt>

                <dd class="opt">

                    <select>
                        <volist name="temps" id="vo">
                            <option name="template" value="{$vo.id}">{$vo.tpl_title}</option>
                        </volist>
                    </select>

                    <p class="notic">微信模板消息模板</p>

                </dd>

            </dl>
            <dl class="row">

                <dt class="tit">

                    <label><em>*</em>发送范围</label>

                </dt>

                <dd class="opt">

                    <input name="send_area" type="radio" value="0" <if condition="$wxmessage['send_area'] eq 0">checked</if> ><label>指定部分人</label>

                    <input name="send_area" type="radio" value="1" <if condition="$wxmessage['send_area'] eq 1">checked</if> ><label>全部</label>

                </dd>

            </dl>
            <dl class="row select_user">

                <dt class="tit">

                    <label><em>*</em>选择会员</label>

                </dt>

                <dd class="opt">
                <textarea name="user_list" style="width:80%;height: 400px" id="user_list" placeholder="会员之间请用逗号隔开">{$wxmessage.user_list|shownickname=###}</textarea>
                <div><a class="btn red send_user" style="border:1px solid red;background: #eee;padding:3px 5px;border-radius: 5px;cursor:pointer;" data-url="{:U('WxMessage/select_user',array('cid'=>$list[id]))}"><i class="fa fa-search"></i>选择会员</a></div>
                </dd>


            </dl>
             <dl class="row sendnum">

                <dt class="tit">

                    <label><em>*</em>发送人数</label>

                </dt>

                <dd class="opt">
                    <input type="text" id="send_num" name="send_num" value="{$wxmessage.user_list|shownickname|count_length=###}" onfocus="this.blur()">
                </dd>


            </dl>

            <div class="bot"><a onclick="$('#handleposition').submit();" class="ncap-btn-big ncap-btn-green">确认提交</a></div>

            

        </div>

    </form>

</div>

<script type="text/javascript">

    $('input[type="radio"]').click(function(){

        if($(this).val() == 1){
            $('.select_user').hide();
        }else{
            $('.select_user').show();
        }

    })


    $('#user_list').change(function(){
       count_user();
    })

    function count_user(){
        var user_list=$.trim($('#user_list').val());
        user_list=user_list.replace(/，/g,',').substr(0,user_list.length-1);
        var userlist=user_list.split(',');
        $('#send_num').val(userlist.length);
    }

 $('.send_user').click(function(){

        var url = $(this).attr('data-url');

        layer.open({

            type: 2,

            title: '请选择会员',

            shadeClose: true,

            shade: 0.5,

            area: ['90%', '85%'],

            content: url,

        });

    });


</script>

</body>

</html>